
/*************************
Data analysis GameChoice2 - February 2018
*****************************/

 
/*************
1) opening
*************/
clear
set more off
cap log close
*set mem 200m


/***************
2) open data
***************/
use "C:\Users\Astrid Dannenberg\Documents\Ada\Scott\Experiments\5. Experiment\Results\tests_data.dta", clear


/***************
3) Labeling and definitions
***************/

/*** Treatment labels ***/

label define treatment 1 "Unilateral-High", add
label define treatment 2 "Majority-High", add
label define treatment 3 "Multilateral-High", add
label define treatment 4 "Unilateral-Low", add
label define treatment 5 "Majority-Low", add
label define treatment 6 "Multilateral-Low", add

label values treatment treatment


/*** Average contribution per group and round ***/

by group, sort : egen mean_v1_r1 = mean(v1_r1)
by group, sort : egen mean_v1_r2 = mean(v1_r2)
by group, sort : egen mean_v1_r3 = mean(v1_r3)
by group, sort : egen mean_v1_r4 = mean(v1_r4)
by group, sort : egen mean_v1_r5 = mean(v1_r5)

by group, sort : egen mean_v2_r1 = mean(v2_r1)
by group, sort : egen mean_v2_r2 = mean(v2_r2)
by group, sort : egen mean_v2_r3 = mean(v2_r3)
by group, sort : egen mean_v2_r4 = mean(v2_r4)
by group, sort : egen mean_v2_r5 = mean(v2_r5)

by group, sort : egen mean_v3_r1 = mean(v3_r1)
by group, sort : egen mean_v3_r2 = mean(v3_r2)
by group, sort : egen mean_v3_r3 = mean(v3_r3)
by group, sort : egen mean_v3_r4 = mean(v3_r4)
by group, sort : egen mean_v3_r5 = mean(v3_r5)

by group, sort : egen mean_v4_r1 = mean(v4_r1)
by group, sort : egen mean_v4_r2 = mean(v4_r2)
by group, sort : egen mean_v4_r3 = mean(v4_r3)
by group, sort : egen mean_v4_r4 = mean(v4_r4)
by group, sort : egen mean_v4_r5 = mean(v4_r5)

by group, sort : egen mean_v5_r1 = mean(v5_r1)
by group, sort : egen mean_v5_r2 = mean(v5_r2)
by group, sort : egen mean_v5_r3 = mean(v5_r3)
by group, sort : egen mean_v5_r4 = mean(v5_r4)
by group, sort : egen mean_v5_r5 = mean(v5_r5)


/*** Average contribution per player and phase ***/

gen v1_r1_5 = (v1_r1 + v1_r2 + v1_r3 + v1_r4 + v1_r5) / 5
gen v2_r1_5 = (v2_r1 + v2_r2 + v2_r3 + v2_r4 + v2_r5) / 5
gen v3_r1_5 = (v3_r1 + v3_r2 + v3_r3 + v3_r4 + v3_r5) / 5
gen v4_r1_5 = (v4_r1 + v4_r2 + v4_r3 + v4_r4 + v4_r5) / 5
gen v5_r1_5 = (v5_r1 + v5_r2 + v5_r3 + v5_r4 + v5_r5) / 5

gen v1_sum_r1_5 = (v1_r1 + v1_r2 + v1_r3 + v1_r4 + v1_r5)
gen v2_sum_r1_5 = (v2_r1 + v2_r2 + v2_r3 + v2_r4 + v2_r5)
gen v3_sum_r1_5 = (v3_r1 + v3_r2 + v3_r3 + v3_r4 + v3_r5)
gen v4_sum_r1_5 = (v4_r1 + v4_r2 + v4_r3 + v4_r4 + v4_r5)
gen v5_sum_r1_5 = (v5_r1 + v5_r2 + v5_r3 + v5_r4 + v5_r5)


/*** Average contribution per group and phase ***/

gen mean_v1_r1_5 = (mean_v1_r1 + mean_v1_r2 + mean_v1_r3 + mean_v1_r4 + mean_v1_r5) / 5
gen mean_v2_r1_5 = (mean_v2_r1 + mean_v2_r2 + mean_v2_r3 + mean_v2_r4 + mean_v2_r5) / 5
gen mean_v3_r1_5 = (mean_v3_r1 + mean_v3_r2 + mean_v3_r3 + mean_v3_r4 + mean_v3_r5) / 5
gen mean_v4_r1_5 = (mean_v4_r1 + mean_v4_r2 + mean_v4_r3 + mean_v4_r4 + mean_v4_r5) / 5
gen mean_v5_r1_5 = (mean_v5_r1 + mean_v5_r2 + mean_v5_r3 + mean_v5_r4 + mean_v5_r5) / 5

gen mean_v1_5_r1_5 = (mean_v1_r1_5 + mean_v2_r1_5 + mean_v3_r1_5 + mean_v4_r1_5 + mean_v5_r1_5) / 5


/*** Aggregate contribution per group and round ***/

by group, sort : egen sum_v1_r1 = sum(v1_r1)
by group, sort : egen sum_v1_r2 = sum(v1_r2)
by group, sort : egen sum_v1_r3 = sum(v1_r3)
by group, sort : egen sum_v1_r4 = sum(v1_r4)
by group, sort : egen sum_v1_r5 = sum(v1_r5)

by group, sort : egen sum_v2_r1 = sum(v2_r1)
by group, sort : egen sum_v2_r2 = sum(v2_r2)
by group, sort : egen sum_v2_r3 = sum(v2_r3)
by group, sort : egen sum_v2_r4 = sum(v2_r4)
by group, sort : egen sum_v2_r5 = sum(v2_r5)

by group, sort : egen sum_v3_r1 = sum(v3_r1)
by group, sort : egen sum_v3_r2 = sum(v3_r2)
by group, sort : egen sum_v3_r3 = sum(v3_r3)
by group, sort : egen sum_v3_r4 = sum(v3_r4)
by group, sort : egen sum_v3_r5 = sum(v3_r5)

by group, sort : egen sum_v4_r1 = sum(v4_r1)
by group, sort : egen sum_v4_r2 = sum(v4_r2)
by group, sort : egen sum_v4_r3 = sum(v4_r3)
by group, sort : egen sum_v4_r4 = sum(v4_r4)
by group, sort : egen sum_v4_r5 = sum(v4_r5)

by group, sort : egen sum_v5_r1 = sum(v5_r1)
by group, sort : egen sum_v5_r2 = sum(v5_r2)
by group, sort : egen sum_v5_r3 = sum(v5_r3)
by group, sort : egen sum_v5_r4 = sum(v5_r4)
by group, sort : egen sum_v5_r5 = sum(v5_r5)


/*** Aggregate contribution per group and phase ***/

gen sum_v1_r1_5 = (sum_v1_r1 + sum_v1_r2 + sum_v1_r3 + sum_v1_r4 + sum_v1_r5) / 5
gen sum_v2_r1_5 = (sum_v2_r1 + sum_v2_r2 + sum_v2_r3 + sum_v2_r4 + sum_v2_r5) / 5
gen sum_v3_r1_5 = (sum_v3_r1 + sum_v3_r2 + sum_v3_r3 + sum_v3_r4 + sum_v3_r5) / 5
gen sum_v4_r1_5 = (sum_v4_r1 + sum_v4_r2 + sum_v4_r3 + sum_v4_r4 + sum_v4_r5) / 5
gen sum_v5_r1_5 = (sum_v5_r1 + sum_v5_r2 + sum_v5_r3 + sum_v5_r4 + sum_v5_r5) / 5


/*** Payoffs in high treatments ***/

gen v1_p1 = 2*sum_v1_r1 + 5*(1-v1_r1) + 12 if g1==1 & treatment<=3
gen v1_p2 = 2*sum_v1_r2 + 5*(1-v1_r2) + 12 if g1==1 & treatment<=3
gen v1_p3 = 2*sum_v1_r3 + 5*(1-v1_r3) + 12 if g1==1 & treatment<=3
gen v1_p4 = 2*sum_v1_r4 + 5*(1-v1_r4) + 12 if g1==1 & treatment<=3
gen v1_p5 = 2*sum_v1_r5 + 5*(1-v1_r5) + 12 if g1==1 & treatment<=3


gen v2_p1 = 2*sum_v2_r1 + 5*(1-v2_r1) + 12 if g2==1 & treatment<=3
gen v2_p2 = 2*sum_v2_r2 + 5*(1-v2_r2) + 12 if g2==1 & treatment<=3
gen v2_p3 = 2*sum_v2_r3 + 5*(1-v2_r3) + 12 if g2==1 & treatment<=3
gen v2_p4 = 2*sum_v2_r4 + 5*(1-v2_r4) + 12 if g2==1 & treatment<=3
gen v2_p5 = 2*sum_v2_r5 + 5*(1-v2_r5) + 12 if g2==1 & treatment<=3

replace v2_p1 = 5*(sum_v2_r1-1) + 2 if g2==0 & v2_r1==1 & treatment<=3
replace v2_p2 = 5*(sum_v2_r2-1) + 2 if g2==0 & v2_r2==1 & treatment<=3
replace v2_p3 = 5*(sum_v2_r3-1) + 2 if g2==0 & v2_r3==1 & treatment<=3
replace v2_p4 = 5*(sum_v2_r4-1) + 2 if g2==0 & v2_r4==1 & treatment<=3
replace v2_p5 = 5*(sum_v2_r5-1) + 2 if g2==0 & v2_r5==1 & treatment<=3

replace v2_p1 = 17 - sum_v2_r1 if g2==0 & v2_r1==0 & treatment<=3
replace v2_p2 = 17 - sum_v2_r2 if g2==0 & v2_r2==0 & treatment<=3
replace v2_p3 = 17 - sum_v2_r3 if g2==0 & v2_r3==0 & treatment<=3
replace v2_p4 = 17 - sum_v2_r4 if g2==0 & v2_r4==0 & treatment<=3
replace v2_p5 = 17 - sum_v2_r5 if g2==0 & v2_r5==0 & treatment<=3


gen v3_p1 = 2*sum_v3_r1 + 5*(1-v3_r1) + 12 if g3==1 & treatment<=3
gen v3_p2 = 2*sum_v3_r2 + 5*(1-v3_r2) + 12 if g3==1 & treatment<=3
gen v3_p3 = 2*sum_v3_r3 + 5*(1-v3_r3) + 12 if g3==1 & treatment<=3
gen v3_p4 = 2*sum_v3_r4 + 5*(1-v3_r4) + 12 if g3==1 & treatment<=3
gen v3_p5 = 2*sum_v3_r5 + 5*(1-v3_r5) + 12 if g3==1 & treatment<=3

replace v3_p1 = 5*(sum_v3_r1-1) + 2 if g3==0 & v3_r1==1 & treatment<=3
replace v3_p2 = 5*(sum_v3_r2-1) + 2 if g3==0 & v3_r2==1 & treatment<=3
replace v3_p3 = 5*(sum_v3_r3-1) + 2 if g3==0 & v3_r3==1 & treatment<=3
replace v3_p4 = 5*(sum_v3_r4-1) + 2 if g3==0 & v3_r4==1 & treatment<=3
replace v3_p5 = 5*(sum_v3_r5-1) + 2 if g3==0 & v3_r5==1 & treatment<=3

replace v3_p1 = 17 - sum_v3_r1 if g3==0 & v3_r1==0 & treatment<=3
replace v3_p2 = 17 - sum_v3_r2 if g3==0 & v3_r2==0 & treatment<=3
replace v3_p3 = 17 - sum_v3_r3 if g3==0 & v3_r3==0 & treatment<=3
replace v3_p4 = 17 - sum_v3_r4 if g3==0 & v3_r4==0 & treatment<=3
replace v3_p5 = 17 - sum_v3_r5 if g3==0 & v3_r5==0 & treatment<=3


gen v4_p1 = 2*sum_v4_r1 + 5*(1-v4_r1) + 12 if g4==1 & treatment<=3
gen v4_p2 = 2*sum_v4_r2 + 5*(1-v4_r2) + 12 if g4==1 & treatment<=3
gen v4_p3 = 2*sum_v4_r3 + 5*(1-v4_r3) + 12 if g4==1 & treatment<=3
gen v4_p4 = 2*sum_v4_r4 + 5*(1-v4_r4) + 12 if g4==1 & treatment<=3
gen v4_p5 = 2*sum_v4_r5 + 5*(1-v4_r5) + 12 if g4==1 & treatment<=3

replace v4_p1 = 5*(sum_v4_r1-1) + 2 if g4==0 & v4_r1==1 & treatment<=3
replace v4_p2 = 5*(sum_v4_r2-1) + 2 if g4==0 & v4_r2==1 & treatment<=3
replace v4_p3 = 5*(sum_v4_r3-1) + 2 if g4==0 & v4_r3==1 & treatment<=3
replace v4_p4 = 5*(sum_v4_r4-1) + 2 if g4==0 & v4_r4==1 & treatment<=3
replace v4_p5 = 5*(sum_v4_r5-1) + 2 if g4==0 & v4_r5==1 & treatment<=3

replace v4_p1 = 17 - sum_v4_r1 if g4==0 & v4_r1==0 & treatment<=3
replace v4_p2 = 17 - sum_v4_r2 if g4==0 & v4_r2==0 & treatment<=3
replace v4_p3 = 17 - sum_v4_r3 if g4==0 & v4_r3==0 & treatment<=3
replace v4_p4 = 17 - sum_v4_r4 if g4==0 & v4_r4==0 & treatment<=3
replace v4_p5 = 17 - sum_v4_r5 if g4==0 & v4_r5==0 & treatment<=3


gen v5_p1 = 2*sum_v5_r1 + 5*(1-v5_r1) + 12 if g5==1 & treatment<=3
gen v5_p2 = 2*sum_v5_r2 + 5*(1-v5_r2) + 12 if g5==1 & treatment<=3
gen v5_p3 = 2*sum_v5_r3 + 5*(1-v5_r3) + 12 if g5==1 & treatment<=3
gen v5_p4 = 2*sum_v5_r4 + 5*(1-v5_r4) + 12 if g5==1 & treatment<=3
gen v5_p5 = 2*sum_v5_r5 + 5*(1-v5_r5) + 12 if g5==1 & treatment<=3

replace v5_p1 = 5*(sum_v5_r1-1) + 2 if g5==0 & v5_r1==1 & treatment<=3
replace v5_p2 = 5*(sum_v5_r2-1) + 2 if g5==0 & v5_r2==1 & treatment<=3
replace v5_p3 = 5*(sum_v5_r3-1) + 2 if g5==0 & v5_r3==1 & treatment<=3
replace v5_p4 = 5*(sum_v5_r4-1) + 2 if g5==0 & v5_r4==1 & treatment<=3
replace v5_p5 = 5*(sum_v5_r5-1) + 2 if g5==0 & v5_r5==1 & treatment<=3

replace v5_p1 = 17 - sum_v5_r1 if g5==0 & v5_r1==0 & treatment<=3
replace v5_p2 = 17 - sum_v5_r2 if g5==0 & v5_r2==0 & treatment<=3
replace v5_p3 = 17 - sum_v5_r3 if g5==0 & v5_r3==0 & treatment<=3
replace v5_p4 = 17 - sum_v5_r4 if g5==0 & v5_r4==0 & treatment<=3
replace v5_p5 = 17 - sum_v5_r5 if g5==0 & v5_r5==0 & treatment<=3


/*** Payoffs in low treatments ***/

replace v1_p1 = 2*sum_v1_r1 + 5*(1-v1_r1) + 4 if g1==1 & treatment>3
replace v1_p2 = 2*sum_v1_r2 + 5*(1-v1_r2) + 4 if g1==1 & treatment>3
replace v1_p3 = 2*sum_v1_r3 + 5*(1-v1_r3) + 4 if g1==1 & treatment>3
replace v1_p4 = 2*sum_v1_r4 + 5*(1-v1_r4) + 4 if g1==1 & treatment>3
replace v1_p5 = 2*sum_v1_r5 + 5*(1-v1_r5) + 4 if g1==1 & treatment>3


replace v2_p1 = 2*sum_v2_r1 + 5*(1-v2_r1) + 4 if g2==1 & treatment>3
replace v2_p2 = 2*sum_v2_r2 + 5*(1-v2_r2) + 4 if g2==1 & treatment>3
replace v2_p3 = 2*sum_v2_r3 + 5*(1-v2_r3) + 4 if g2==1 & treatment>3
replace v2_p4 = 2*sum_v2_r4 + 5*(1-v2_r4) + 4 if g2==1 & treatment>3
replace v2_p5 = 2*sum_v2_r5 + 5*(1-v2_r5) + 4 if g2==1 & treatment>3

replace v2_p1 = 3*(sum_v2_r1-1) + 2 if g2==0 & v2_r1==1 & treatment>3
replace v2_p2 = 3*(sum_v2_r2-1) + 2 if g2==0 & v2_r2==1 & treatment>3
replace v2_p3 = 3*(sum_v2_r3-1) + 2 if g2==0 & v2_r3==1 & treatment>3
replace v2_p4 = 3*(sum_v2_r4-1) + 2 if g2==0 & v2_r4==1 & treatment>3
replace v2_p5 = 3*(sum_v2_r5-1) + 2 if g2==0 & v2_r5==1 & treatment>3

replace v2_p1 = sum_v2_r1 + 9 if g2==0 & v2_r1==0 & treatment>3
replace v2_p2 = sum_v2_r2 + 9 if g2==0 & v2_r2==0 & treatment>3
replace v2_p3 = sum_v2_r3 + 9 if g2==0 & v2_r3==0 & treatment>3
replace v2_p4 = sum_v2_r4 + 9 if g2==0 & v2_r4==0 & treatment>3
replace v2_p5 = sum_v2_r5 + 9 if g2==0 & v2_r5==0 & treatment>3


replace v3_p1 = 2*sum_v3_r1 + 5*(1-v3_r1) + 4 if g3==1 & treatment>3
replace v3_p2 = 2*sum_v3_r2 + 5*(1-v3_r2) + 4 if g3==1 & treatment>3
replace v3_p3 = 2*sum_v3_r3 + 5*(1-v3_r3) + 4 if g3==1 & treatment>3
replace v3_p4 = 2*sum_v3_r4 + 5*(1-v3_r4) + 4 if g3==1 & treatment>3
replace v3_p5 = 2*sum_v3_r5 + 5*(1-v3_r5) + 4 if g3==1 & treatment>3

replace v3_p1 = 3*(sum_v3_r1-1) + 2 if g3==0 & v3_r1==1 & treatment>3
replace v3_p2 = 3*(sum_v3_r2-1) + 2 if g3==0 & v3_r2==1 & treatment>3
replace v3_p3 = 3*(sum_v3_r3-1) + 2 if g3==0 & v3_r3==1 & treatment>3
replace v3_p4 = 3*(sum_v3_r4-1) + 2 if g3==0 & v3_r4==1 & treatment>3
replace v3_p5 = 3*(sum_v3_r5-1) + 2 if g3==0 & v3_r5==1 & treatment>3

replace v3_p1 = sum_v3_r1 + 9 if g3==0 & v3_r1==0 & treatment>3
replace v3_p2 = sum_v3_r2 + 9 if g3==0 & v3_r2==0 & treatment>3
replace v3_p3 = sum_v3_r3 + 9 if g3==0 & v3_r3==0 & treatment>3
replace v3_p4 = sum_v3_r4 + 9 if g3==0 & v3_r4==0 & treatment>3
replace v3_p5 = sum_v3_r5 + 9 if g3==0 & v3_r5==0 & treatment>3


replace v4_p1 = 2*sum_v4_r1 + 5*(1-v4_r1) + 4 if g4==1 & treatment>3
replace v4_p2 = 2*sum_v4_r2 + 5*(1-v4_r2) + 4 if g4==1 & treatment>3
replace v4_p3 = 2*sum_v4_r3 + 5*(1-v4_r3) + 4 if g4==1 & treatment>3
replace v4_p4 = 2*sum_v4_r4 + 5*(1-v4_r4) + 4 if g4==1 & treatment>3
replace v4_p5 = 2*sum_v4_r5 + 5*(1-v4_r5) + 4 if g4==1 & treatment>3

replace v4_p1 = 3*(sum_v4_r1-1) + 2 if g4==0 & v4_r1==1 & treatment>3
replace v4_p2 = 3*(sum_v4_r2-1) + 2 if g4==0 & v4_r2==1 & treatment>3
replace v4_p3 = 3*(sum_v4_r3-1) + 2 if g4==0 & v4_r3==1 & treatment>3
replace v4_p4 = 3*(sum_v4_r4-1) + 2 if g4==0 & v4_r4==1 & treatment>3
replace v4_p5 = 3*(sum_v4_r5-1) + 2 if g4==0 & v4_r5==1 & treatment>3

replace v4_p1 = sum_v4_r1 + 9 if g4==0 & v4_r1==0 & treatment>3
replace v4_p2 = sum_v4_r2 + 9 if g4==0 & v4_r2==0 & treatment>3
replace v4_p3 = sum_v4_r3 + 9 if g4==0 & v4_r3==0 & treatment>3
replace v4_p4 = sum_v4_r4 + 9 if g4==0 & v4_r4==0 & treatment>3
replace v4_p5 = sum_v4_r5 + 9 if g4==0 & v4_r5==0 & treatment>3


replace v5_p1 = 2*sum_v5_r1 + 5*(1-v5_r1) + 4 if g5==1 & treatment>3
replace v5_p2 = 2*sum_v5_r2 + 5*(1-v5_r2) + 4 if g5==1 & treatment>3
replace v5_p3 = 2*sum_v5_r3 + 5*(1-v5_r3) + 4 if g5==1 & treatment>3
replace v5_p4 = 2*sum_v5_r4 + 5*(1-v5_r4) + 4 if g5==1 & treatment>3
replace v5_p5 = 2*sum_v5_r5 + 5*(1-v5_r5) + 4 if g5==1 & treatment>3

replace v5_p1 = 3*(sum_v5_r1-1) + 2 if g5==0 & v5_r1==1 & treatment>3
replace v5_p2 = 3*(sum_v5_r2-1) + 2 if g5==0 & v5_r2==1 & treatment>3
replace v5_p3 = 3*(sum_v5_r3-1) + 2 if g5==0 & v5_r3==1 & treatment>3
replace v5_p4 = 3*(sum_v5_r4-1) + 2 if g5==0 & v5_r4==1 & treatment>3
replace v5_p5 = 3*(sum_v5_r5-1) + 2 if g5==0 & v5_r5==1 & treatment>3

replace v5_p1 = sum_v5_r1 + 9 if g5==0 & v5_r1==0 & treatment>3
replace v5_p2 = sum_v5_r2 + 9 if g5==0 & v5_r2==0 & treatment>3
replace v5_p3 = sum_v5_r3 + 9 if g5==0 & v5_r3==0 & treatment>3
replace v5_p4 = sum_v5_r4 + 9 if g5==0 & v5_r4==0 & treatment>3
replace v5_p5 = sum_v5_r5 + 9 if g5==0 & v5_r5==0 & treatment>3


/*** Average payoff per player and phase ***/

gen v1_p1_5 = (v1_p1 + v1_p2 + v1_p3 + v1_p4 + v1_p5) / 5
gen v2_p1_5 = (v2_p1 + v2_p2 + v2_p3 + v2_p4 + v2_p5) / 5
gen v3_p1_5 = (v3_p1 + v3_p2 + v3_p3 + v3_p4 + v3_p5) / 5
gen v4_p1_5 = (v4_p1 + v4_p2 + v4_p3 + v4_p4 + v4_p5) / 5
gen v5_p1_5 = (v5_p1 + v5_p2 + v5_p3 + v5_p4 + v5_p5) / 5

gen v1_5_p1_5 = (v1_p1_5 + v2_p1_5 + v3_p1_5 + v4_p1_5 + v5_p1_5) / 5

/*** Average payoff per group and round ***/

by group, sort : egen mean_v1_p1 = mean(v1_p1)
by group, sort : egen mean_v1_p2 = mean(v1_p2)
by group, sort : egen mean_v1_p3 = mean(v1_p3)
by group, sort : egen mean_v1_p4 = mean(v1_p4)
by group, sort : egen mean_v1_p5 = mean(v1_p5)

by group, sort : egen mean_v2_p1 = mean(v2_p1)
by group, sort : egen mean_v2_p2 = mean(v2_p2)
by group, sort : egen mean_v2_p3 = mean(v2_p3)
by group, sort : egen mean_v2_p4 = mean(v2_p4)
by group, sort : egen mean_v2_p5 = mean(v2_p5)

by group, sort : egen mean_v3_p1 = mean(v3_p1)
by group, sort : egen mean_v3_p2 = mean(v3_p2)
by group, sort : egen mean_v3_p3 = mean(v3_p3)
by group, sort : egen mean_v3_p4 = mean(v3_p4)
by group, sort : egen mean_v3_p5 = mean(v3_p5)

by group, sort : egen mean_v4_p1 = mean(v4_p1)
by group, sort : egen mean_v4_p2 = mean(v4_p2)
by group, sort : egen mean_v4_p3 = mean(v4_p3)
by group, sort : egen mean_v4_p4 = mean(v4_p4)
by group, sort : egen mean_v4_p5 = mean(v4_p5)

by group, sort : egen mean_v5_p1 = mean(v5_p1)
by group, sort : egen mean_v5_p2 = mean(v5_p2)
by group, sort : egen mean_v5_p3 = mean(v5_p3)
by group, sort : egen mean_v5_p4 = mean(v5_p4)
by group, sort : egen mean_v5_p5 = mean(v5_p5)


/*** Average payoff per group and phase ***/

gen mean_v1_p1_5 = (mean_v1_p1 + mean_v1_p2 + mean_v1_p3 + mean_v1_p4 + mean_v1_p5) / 5
gen mean_v2_p1_5 = (mean_v2_p1 + mean_v2_p2 + mean_v2_p3 + mean_v2_p4 + mean_v2_p5) / 5
gen mean_v3_p1_5 = (mean_v3_p1 + mean_v3_p2 + mean_v3_p3 + mean_v3_p4 + mean_v3_p5) / 5
gen mean_v4_p1_5 = (mean_v4_p1 + mean_v4_p2 + mean_v4_p3 + mean_v4_p4 + mean_v4_p5) / 5
gen mean_v5_p1_5 = (mean_v5_p1 + mean_v5_p2 + mean_v5_p3 + mean_v5_p4 + mean_v5_p5) / 5

gen mean_v1_5_p1_5 = (mean_v1_p1_5 + mean_v2_p1_5 + mean_v3_p1_5 + mean_v4_p1_5 + mean_v5_p1_5) / 5

/***************
4) Correlations between ex ante questions and first voting
***************/

egen mean_bcg = mean(bcg)
gen tt_bcg = (2/3)*mean_bcg
gen diff_bcg = sqrt((bcg - tt_bcg)*(bcg - tt_bcg))

spearman bcg v2
spearman diff_bcg v2
spearman f1 v2
spearman f18 v2
spearman v1_r1 v2

by treatment, sort: spearman bcg v2
by treatment, sort: spearman diff_bcg v2
by treatment, sort: spearman f1 v2
by treatment, sort: spearman f18 v2
by treatment, sort: spearman v1_r1 v2


/***************
5) Difference in playing A or B
***************/

/*** Game choice between institutions ***/

tab g2 treatment if (treatment==1|treatment==2) & subject==1, chi2 exact
tab g2 treatment if (treatment==1|treatment==3) & subject==1, chi2 exact
tab g2 treatment if (treatment==2|treatment==3) & subject==1, chi2 exact

tab g3 treatment if (treatment==1|treatment==2) & subject==1, chi2 exact
tab g3 treatment if (treatment==1|treatment==3) & subject==1, chi2 exact
tab g3 treatment if (treatment==2|treatment==3) & subject==1, chi2 exact

tab g4 treatment if (treatment==1|treatment==2) & subject==1, chi2 exact
tab g4 treatment if (treatment==1|treatment==3) & subject==1, chi2 exact
tab g4 treatment if (treatment==2|treatment==3) & subject==1, chi2 exact

tab g5 treatment if (treatment==1|treatment==2) & subject==1, chi2 exact
tab g5 treatment if (treatment==1|treatment==3) & subject==1, chi2 exact
tab g5 treatment if (treatment==2|treatment==3) & subject==1, chi2 exact


tab g2 treatment if (treatment==4|treatment==5) & subject==1, chi2 exact
tab g2 treatment if (treatment==4|treatment==6) & subject==1, chi2 exact
tab g2 treatment if (treatment==5|treatment==6) & subject==1, chi2 exact

tab g3 treatment if (treatment==4|treatment==5) & subject==1, chi2 exact
tab g3 treatment if (treatment==4|treatment==6) & subject==1, chi2 exact
tab g3 treatment if (treatment==5|treatment==6) & subject==1, chi2 exact

tab g4 treatment if (treatment==4|treatment==5) & subject==1, chi2 exact
tab g4 treatment if (treatment==4|treatment==6) & subject==1, chi2 exact
tab g4 treatment if (treatment==5|treatment==6) & subject==1, chi2 exact

tab g5 treatment if (treatment==4|treatment==5) & subject==1, chi2 exact
tab g5 treatment if (treatment==4|treatment==6) & subject==1, chi2 exact
tab g5 treatment if (treatment==5|treatment==6) & subject==1, chi2 exact

/*** Game choice between high and low ***/

tab g2 treatment if (treatment==1|treatment==4) & subject==1, chi2 exact
tab g2 treatment if (treatment==2|treatment==5) & subject==1, chi2 exact
tab g2 treatment if (treatment==3|treatment==6) & subject==1, chi2 exact

tab g3 treatment if (treatment==1|treatment==4) & subject==1, chi2 exact
tab g3 treatment if (treatment==2|treatment==5) & subject==1, chi2 exact
tab g3 treatment if (treatment==3|treatment==6) & subject==1, chi2 exact

tab g4 treatment if (treatment==1|treatment==4) & subject==1, chi2 exact
tab g4 treatment if (treatment==2|treatment==5) & subject==1, chi2 exact
tab g4 treatment if (treatment==3|treatment==6) & subject==1, chi2 exact

tab g5 treatment if (treatment==1|treatment==4) & subject==1, chi2 exact
tab g5 treatment if (treatment==2|treatment==5) & subject==1, chi2 exact
tab g5 treatment if (treatment==3|treatment==6) & subject==1, chi2 exact


/*** Voting and selected game ***/

tab v2 if treatment==1
tab v3 if treatment==1
tab v4 if treatment==1
tab v5 if treatment==1

tab v2 if treatment==2
tab v3 if treatment==2
tab v4 if treatment==2
tab v5 if treatment==2

tab v2 if treatment==3
tab v3 if treatment==3
tab v4 if treatment==3
tab v5 if treatment==3

tab v2 if treatment==4
tab v3 if treatment==4
tab v4 if treatment==4
tab v5 if treatment==4

tab v2 if treatment==5
tab v3 if treatment==5
tab v4 if treatment==5
tab v5 if treatment==5

tab v2 if treatment==6
tab v3 if treatment==6
tab v4 if treatment==6
tab v5 if treatment==6


tab g2 if treatment==1 & subject==1
tab g3 if treatment==1 & subject==1
tab g4 if treatment==1 & subject==1
tab g5 if treatment==1 & subject==1

tab g2 if treatment==2 & subject==1
tab g3 if treatment==2 & subject==1
tab g4 if treatment==2 & subject==1
tab g5 if treatment==2 & subject==1

tab g2 if treatment==3 & subject==1
tab g3 if treatment==3 & subject==1
tab g4 if treatment==3 & subject==1
tab g5 if treatment==3 & subject==1

tab g2 if treatment==4 & subject==1
tab g3 if treatment==4 & subject==1
tab g4 if treatment==4 & subject==1
tab g5 if treatment==4 & subject==1

tab g2 if treatment==5 & subject==1
tab g3 if treatment==5 & subject==1
tab g4 if treatment==5 & subject==1
tab g5 if treatment==5 & subject==1

tab g2 if treatment==6 & subject==1
tab g3 if treatment==6 & subject==1
tab g4 if treatment==6 & subject==1
tab g5 if treatment==6 & subject==1


/***************
Difference in contributions and payoffs between A and B
***************/

/*** Comparison of contributions between A and B ***/

by g1, sort: summarize mean_v1_r1_5 if treatment==1 & subject==1
by g2, sort: summarize mean_v2_r1_5 if treatment==1 & subject==1
by g3, sort: summarize mean_v3_r1_5 if treatment==1 & subject==1
by g4, sort: summarize mean_v4_r1_5 if treatment==1 & subject==1
by g5, sort: summarize mean_v5_r1_5 if treatment==1 & subject==1

ranksum mean_v2_r1_5 if treatment==1 & subject==1, by(g2)
ranksum mean_v3_r1_5 if treatment==1 & subject==1, by(g3)
ranksum mean_v4_r1_5 if treatment==1 & subject==1, by(g4)
ranksum mean_v5_r1_5 if treatment==1 & subject==1, by(g5)


by g1, sort: summarize mean_v1_r1_5 if treatment==2 & subject==1
by g2, sort: summarize mean_v2_r1_5 if treatment==2 & subject==1
by g3, sort: summarize mean_v3_r1_5 if treatment==2 & subject==1
by g4, sort: summarize mean_v4_r1_5 if treatment==2 & subject==1
by g5, sort: summarize mean_v5_r1_5 if treatment==2 & subject==1

ranksum mean_v2_r1_5 if treatment==2 & subject==1, by(g2)
ranksum mean_v3_r1_5 if treatment==2 & subject==1, by(g3)
ranksum mean_v4_r1_5 if treatment==2 & subject==1, by(g4)
ranksum mean_v5_r1_5 if treatment==2 & subject==1, by(g5)


by g1, sort: summarize mean_v1_r1_5 if treatment==3 & subject==1
by g2, sort: summarize mean_v2_r1_5 if treatment==3 & subject==1
by g3, sort: summarize mean_v3_r1_5 if treatment==3 & subject==1
by g4, sort: summarize mean_v4_r1_5 if treatment==3 & subject==1
by g5, sort: summarize mean_v5_r1_5 if treatment==3 & subject==1

ranksum mean_v2_r1_5 if treatment==3 & subject==1, by(g2)
ranksum mean_v3_r1_5 if treatment==3 & subject==1, by(g3)
ranksum mean_v4_r1_5 if treatment==3 & subject==1, by(g4)
ranksum mean_v5_r1_5 if treatment==3 & subject==1, by(g5)


by g1, sort: summarize mean_v1_r1_5 if treatment==4 & subject==1
by g2, sort: summarize mean_v2_r1_5 if treatment==4 & subject==1
by g3, sort: summarize mean_v3_r1_5 if treatment==4 & subject==1
by g4, sort: summarize mean_v4_r1_5 if treatment==4 & subject==1
by g5, sort: summarize mean_v5_r1_5 if treatment==4 & subject==1

*ranksum mean_v2_r1_5 if treatment==4 & subject==1, by(g2)
ranksum mean_v3_r1_5 if treatment==4 & subject==1, by(g3)
ranksum mean_v4_r1_5 if treatment==4 & subject==1, by(g4)
ranksum mean_v5_r1_5 if treatment==4 & subject==1, by(g5)


by g1, sort: summarize mean_v1_r1_5 if treatment==5 & subject==1
by g2, sort: summarize mean_v2_r1_5 if treatment==5 & subject==1
by g3, sort: summarize mean_v3_r1_5 if treatment==5 & subject==1
by g4, sort: summarize mean_v4_r1_5 if treatment==5 & subject==1
by g5, sort: summarize mean_v5_r1_5 if treatment==5 & subject==1

ranksum mean_v2_r1_5 if treatment==5 & subject==1, by(g2)
ranksum mean_v3_r1_5 if treatment==5 & subject==1, by(g3)
ranksum mean_v4_r1_5 if treatment==5 & subject==1, by(g4)
ranksum mean_v5_r1_5 if treatment==5 & subject==1, by(g5)


by g1, sort: summarize mean_v1_r1_5 if treatment==6 & subject==1
by g2, sort: summarize mean_v2_r1_5 if treatment==6 & subject==1
by g3, sort: summarize mean_v3_r1_5 if treatment==6 & subject==1
by g4, sort: summarize mean_v4_r1_5 if treatment==6 & subject==1
by g5, sort: summarize mean_v5_r1_5 if treatment==6 & subject==1

ranksum mean_v2_r1_5 if treatment==6 & subject==1, by(g2)
ranksum mean_v3_r1_5 if treatment==6 & subject==1, by(g3)
ranksum mean_v4_r1_5 if treatment==6 & subject==1, by(g4)
ranksum mean_v5_r1_5 if treatment==6 & subject==1, by(g5)

/*** Comparison of payoffs between A and B ***/

by g1, sort: summarize mean_v1_p1_5 if treatment==1 & subject==1
by g2, sort: summarize mean_v2_p1_5 if treatment==1 & subject==1
by g3, sort: summarize mean_v3_p1_5 if treatment==1 & subject==1
by g4, sort: summarize mean_v4_p1_5 if treatment==1 & subject==1
by g5, sort: summarize mean_v5_p1_5 if treatment==1 & subject==1

ranksum mean_v2_p1_5 if treatment==1 & subject==1, by(g2)
ranksum mean_v3_p1_5 if treatment==1 & subject==1, by(g3)
ranksum mean_v4_p1_5 if treatment==1 & subject==1, by(g4)
ranksum mean_v5_p1_5 if treatment==1 & subject==1, by(g5)


by g1, sort: summarize mean_v1_p1_5 if treatment==2 & subject==1
by g2, sort: summarize mean_v2_p1_5 if treatment==2 & subject==1
by g3, sort: summarize mean_v3_p1_5 if treatment==2 & subject==1
by g4, sort: summarize mean_v4_p1_5 if treatment==2 & subject==1
by g5, sort: summarize mean_v5_p1_5 if treatment==2 & subject==1

ranksum mean_v2_p1_5 if treatment==2 & subject==1, by(g2)
ranksum mean_v3_p1_5 if treatment==2 & subject==1, by(g3)
ranksum mean_v4_p1_5 if treatment==2 & subject==1, by(g4)
ranksum mean_v5_p1_5 if treatment==2 & subject==1, by(g5)


by g1, sort: summarize mean_v1_p1_5 if treatment==3 & subject==1
by g2, sort: summarize mean_v2_p1_5 if treatment==3 & subject==1
by g3, sort: summarize mean_v3_p1_5 if treatment==3 & subject==1
by g4, sort: summarize mean_v4_p1_5 if treatment==3 & subject==1
by g5, sort: summarize mean_v5_p1_5 if treatment==3 & subject==1

ranksum mean_v2_p1_5 if treatment==3 & subject==1, by(g2)
ranksum mean_v3_p1_5 if treatment==3 & subject==1, by(g3)
ranksum mean_v4_p1_5 if treatment==3 & subject==1, by(g4)
ranksum mean_v5_p1_5 if treatment==3 & subject==1, by(g5)


by g1, sort: summarize mean_v1_p1_5 if treatment==4 & subject==1
by g2, sort: summarize mean_v2_p1_5 if treatment==4 & subject==1
by g3, sort: summarize mean_v3_p1_5 if treatment==4 & subject==1
by g4, sort: summarize mean_v4_p1_5 if treatment==4 & subject==1
by g5, sort: summarize mean_v5_p1_5 if treatment==4 & subject==1

*ranksum mean_v2_p1_5 if treatment==4 & subject==1, by(g2)
ranksum mean_v3_p1_5 if treatment==4 & subject==1, by(g3)
ranksum mean_v4_p1_5 if treatment==4 & subject==1, by(g4)
ranksum mean_v5_p1_5 if treatment==4 & subject==1, by(g5)


by g1, sort: summarize mean_v1_p1_5 if treatment==5 & subject==1
by g2, sort: summarize mean_v2_p1_5 if treatment==5 & subject==1
by g3, sort: summarize mean_v3_p1_5 if treatment==5 & subject==1
by g4, sort: summarize mean_v4_p1_5 if treatment==5 & subject==1
by g5, sort: summarize mean_v5_p1_5 if treatment==5 & subject==1

ranksum mean_v2_p1_5 if treatment==5 & subject==1, by(g2)
ranksum mean_v3_p1_5 if treatment==5 & subject==1, by(g3)
ranksum mean_v4_p1_5 if treatment==5 & subject==1, by(g4)
ranksum mean_v5_p1_5 if treatment==5 & subject==1, by(g5)


by g1, sort: summarize mean_v1_p1_5 if treatment==6 & subject==1
by g2, sort: summarize mean_v2_p1_5 if treatment==6 & subject==1
by g3, sort: summarize mean_v3_p1_5 if treatment==6 & subject==1
by g4, sort: summarize mean_v4_p1_5 if treatment==6 & subject==1
by g5, sort: summarize mean_v5_p1_5 if treatment==6 & subject==1

ranksum mean_v2_p1_5 if treatment==6 & subject==1, by(g2)
ranksum mean_v3_p1_5 if treatment==6 & subject==1, by(g3)
ranksum mean_v4_p1_5 if treatment==6 & subject==1, by(g4)
ranksum mean_v5_p1_5 if treatment==6 & subject==1, by(g5)


/***************
Difference in contributions and payoffs between treatments
***************/

/*** Contributions high treatments ***/

ranksum mean_v1_r1_5 if (treatment==1|treatment==2) & subject==1 & g1==1, by(treatment)
ranksum mean_v1_r1_5 if (treatment==1|treatment==3) & subject==1 & g1==1, by(treatment)
ranksum mean_v1_r1_5 if (treatment==2|treatment==3) & subject==1 & g1==1, by(treatment)

ranksum mean_v2_r1_5 if (treatment==1|treatment==2) & subject==1 & g2==1, by(treatment)
ranksum mean_v2_r1_5 if (treatment==1|treatment==3) & subject==1 & g2==1, by(treatment)
ranksum mean_v2_r1_5 if (treatment==2|treatment==3) & subject==1 & g2==1, by(treatment)

ranksum mean_v2_r1_5 if (treatment==1|treatment==2) & subject==1 & g2==0, by(treatment)
ranksum mean_v2_r1_5 if (treatment==1|treatment==3) & subject==1 & g2==0, by(treatment)
ranksum mean_v2_r1_5 if (treatment==2|treatment==3) & subject==1 & g2==0, by(treatment)

ranksum mean_v2_r1_5 if (treatment==1|treatment==2) & subject==1, by(treatment)
ranksum mean_v2_r1_5 if (treatment==1|treatment==3) & subject==1, by(treatment)
ranksum mean_v2_r1_5 if (treatment==2|treatment==3) & subject==1, by(treatment)

ranksum mean_v3_r1_5 if (treatment==1|treatment==2) & subject==1 & g3==1, by(treatment)
ranksum mean_v3_r1_5 if (treatment==1|treatment==3) & subject==1 & g3==1, by(treatment)
ranksum mean_v3_r1_5 if (treatment==2|treatment==3) & subject==1 & g3==1, by(treatment)

ranksum mean_v3_r1_5 if (treatment==1|treatment==2) & subject==1 & g3==0, by(treatment)
ranksum mean_v3_r1_5 if (treatment==1|treatment==3) & subject==1 & g3==0, by(treatment)
ranksum mean_v3_r1_5 if (treatment==2|treatment==3) & subject==1 & g3==0, by(treatment)

ranksum mean_v3_r1_5 if (treatment==1|treatment==2) & subject==1, by(treatment)
ranksum mean_v3_r1_5 if (treatment==1|treatment==3) & subject==1, by(treatment)
ranksum mean_v3_r1_5 if (treatment==2|treatment==3) & subject==1, by(treatment)

ranksum mean_v4_r1_5 if (treatment==1|treatment==2) & subject==1 & g4==1, by(treatment)
ranksum mean_v4_r1_5 if (treatment==1|treatment==3) & subject==1 & g4==1, by(treatment)
ranksum mean_v4_r1_5 if (treatment==2|treatment==3) & subject==1 & g4==1, by(treatment)

ranksum mean_v4_r1_5 if (treatment==1|treatment==2) & subject==1 & g4==0, by(treatment)
ranksum mean_v4_r1_5 if (treatment==1|treatment==3) & subject==1 & g4==0, by(treatment)
ranksum mean_v4_r1_5 if (treatment==2|treatment==3) & subject==1 & g4==0, by(treatment)

ranksum mean_v4_r1_5 if (treatment==1|treatment==2) & subject==1, by(treatment)
ranksum mean_v4_r1_5 if (treatment==1|treatment==3) & subject==1, by(treatment)
ranksum mean_v4_r1_5 if (treatment==2|treatment==3) & subject==1, by(treatment)

ranksum mean_v5_r1_5 if (treatment==1|treatment==2) & subject==1 & g5==1, by(treatment)
ranksum mean_v5_r1_5 if (treatment==1|treatment==3) & subject==1 & g5==1, by(treatment)
ranksum mean_v5_r1_5 if (treatment==2|treatment==3) & subject==1 & g5==1, by(treatment)

ranksum mean_v5_r1_5 if (treatment==1|treatment==2) & subject==1 & g5==0, by(treatment)
ranksum mean_v5_r1_5 if (treatment==1|treatment==3) & subject==1 & g5==0, by(treatment)
ranksum mean_v5_r1_5 if (treatment==2|treatment==3) & subject==1 & g5==0, by(treatment)

ranksum mean_v5_r1_5 if (treatment==1|treatment==2) & subject==1, by(treatment)
ranksum mean_v5_r1_5 if (treatment==1|treatment==3) & subject==1, by(treatment)
ranksum mean_v5_r1_5 if (treatment==2|treatment==3) & subject==1, by(treatment)


/*** Contributions low treatments ***/

ranksum mean_v1_r1_5 if (treatment==4|treatment==5) & subject==1 & g1==1, by(treatment)
ranksum mean_v1_r1_5 if (treatment==4|treatment==6) & subject==1 & g1==1, by(treatment)
ranksum mean_v1_r1_5 if (treatment==5|treatment==6) & subject==1 & g1==1, by(treatment)

*ranksum mean_v2_r1_5 if (treatment==4|treatment==5) & subject==1 & g2==1, by(treatment)
*ranksum mean_v2_r1_5 if (treatment==4|treatment==6) & subject==1 & g2==1, by(treatment)
ranksum mean_v2_r1_5 if (treatment==5|treatment==6) & subject==1 & g2==1, by(treatment)

ranksum mean_v2_r1_5 if (treatment==4|treatment==5) & subject==1 & g2==0, by(treatment)
ranksum mean_v2_r1_5 if (treatment==4|treatment==6) & subject==1 & g2==0, by(treatment)
ranksum mean_v2_r1_5 if (treatment==5|treatment==6) & subject==1 & g2==0, by(treatment)

ranksum mean_v2_r1_5 if (treatment==4|treatment==5) & subject==1, by(treatment)
ranksum mean_v2_r1_5 if (treatment==4|treatment==6) & subject==1, by(treatment)
ranksum mean_v2_r1_5 if (treatment==5|treatment==6) & subject==1, by(treatment)

ranksum mean_v3_r1_5 if (treatment==4|treatment==5) & subject==1 & g3==1, by(treatment)
ranksum mean_v3_r1_5 if (treatment==4|treatment==6) & subject==1 & g3==1, by(treatment)
ranksum mean_v3_r1_5 if (treatment==5|treatment==6) & subject==1 & g3==1, by(treatment)

ranksum mean_v3_r1_5 if (treatment==4|treatment==5) & subject==1 & g3==0, by(treatment)
ranksum mean_v3_r1_5 if (treatment==4|treatment==6) & subject==1 & g3==0, by(treatment)
ranksum mean_v3_r1_5 if (treatment==5|treatment==6) & subject==1 & g3==0, by(treatment)

ranksum mean_v3_r1_5 if (treatment==4|treatment==5) & subject==1, by(treatment)
ranksum mean_v3_r1_5 if (treatment==4|treatment==6) & subject==1, by(treatment)
ranksum mean_v3_r1_5 if (treatment==5|treatment==6) & subject==1, by(treatment)

ranksum mean_v4_r1_5 if (treatment==4|treatment==5) & subject==1 & g4==1, by(treatment)
ranksum mean_v4_r1_5 if (treatment==4|treatment==6) & subject==1 & g4==1, by(treatment)
ranksum mean_v4_r1_5 if (treatment==5|treatment==6) & subject==1 & g4==1, by(treatment)

ranksum mean_v4_r1_5 if (treatment==4|treatment==5) & subject==1 & g4==0, by(treatment)
ranksum mean_v4_r1_5 if (treatment==4|treatment==6) & subject==1 & g4==0, by(treatment)
ranksum mean_v4_r1_5 if (treatment==5|treatment==6) & subject==1 & g4==0, by(treatment)

ranksum mean_v4_r1_5 if (treatment==4|treatment==5) & subject==1, by(treatment)
ranksum mean_v4_r1_5 if (treatment==4|treatment==6) & subject==1, by(treatment)
ranksum mean_v4_r1_5 if (treatment==5|treatment==6) & subject==1, by(treatment)

ranksum mean_v5_r1_5 if (treatment==4|treatment==5) & subject==1 & g5==1, by(treatment)
ranksum mean_v5_r1_5 if (treatment==4|treatment==6) & subject==1 & g5==1, by(treatment)
ranksum mean_v5_r1_5 if (treatment==5|treatment==6) & subject==1 & g5==1, by(treatment)

ranksum mean_v5_r1_5 if (treatment==4|treatment==5) & subject==1 & g5==0, by(treatment)
ranksum mean_v5_r1_5 if (treatment==4|treatment==6) & subject==1 & g5==0, by(treatment)
ranksum mean_v5_r1_5 if (treatment==5|treatment==6) & subject==1 & g5==0, by(treatment)

ranksum mean_v5_r1_5 if (treatment==4|treatment==5) & subject==1, by(treatment)
ranksum mean_v5_r1_5 if (treatment==4|treatment==6) & subject==1, by(treatment)
ranksum mean_v5_r1_5 if (treatment==5|treatment==6) & subject==1, by(treatment)

*** Comparison of contributions between A and B over all phases ***/

gen mean_a_v1_r1_5 = mean_v1_r1_5 if g1==1
gen mean_a_v2_r1_5 = mean_v2_r1_5 if g2==1
gen mean_a_v3_r1_5 = mean_v3_r1_5 if g3==1
gen mean_a_v4_r1_5 = mean_v4_r1_5 if g4==1
gen mean_a_v5_r1_5 = mean_v5_r1_5 if g5==1

gen mean_b_v1_r1_5 = mean_v1_r1_5 if g1==0
gen mean_b_v2_r1_5 = mean_v2_r1_5 if g2==0
gen mean_b_v3_r1_5 = mean_v3_r1_5 if g3==0
gen mean_b_v4_r1_5 = mean_v4_r1_5 if g4==0
gen mean_b_v5_r1_5 = mean_v5_r1_5 if g5==0

replace mean_a_v1_r1_5 = 0 if mean_a_v1_r1_5==.
replace mean_a_v2_r1_5 = 0 if mean_a_v2_r1_5==.
replace mean_a_v3_r1_5 = 0 if mean_a_v3_r1_5==.
replace mean_a_v4_r1_5 = 0 if mean_a_v4_r1_5==.
replace mean_a_v5_r1_5 = 0 if mean_a_v5_r1_5==.

replace mean_b_v1_r1_5 = 0 if mean_b_v1_r1_5==.
replace mean_b_v2_r1_5 = 0 if mean_b_v2_r1_5==.
replace mean_b_v3_r1_5 = 0 if mean_b_v3_r1_5==.
replace mean_b_v4_r1_5 = 0 if mean_b_v4_r1_5==.
replace mean_b_v5_r1_5 = 0 if mean_b_v5_r1_5==.

gen a_v1_5 = g1+g2+g3+g4+g5
gen b_v1_5 = 5 - a_v1_5

gen mean_a_v1_5_r1_5 = (mean_a_v1_r1_5+mean_a_v2_r1_5+mean_a_v3_r1_5+mean_a_v4_r1_5+mean_a_v5_r1_5)/a_v1_5
gen mean_b_v1_5_r1_5 = (mean_b_v1_r1_5+mean_b_v2_r1_5+mean_b_v3_r1_5+mean_b_v4_r1_5+mean_b_v5_r1_5)/b_v1_5

ranksum mean_a_v1_5_r1_5 if (treatment==1|treatment==2) & subject==1, by(treatment)
ranksum mean_a_v1_5_r1_5 if (treatment==1|treatment==3) & subject==1, by(treatment)
ranksum mean_a_v1_5_r1_5 if (treatment==2|treatment==3) & subject==1, by(treatment)

ranksum mean_b_v1_5_r1_5 if (treatment==1|treatment==2) & subject==1, by(treatment)
ranksum mean_b_v1_5_r1_5 if (treatment==1|treatment==3) & subject==1, by(treatment)
ranksum mean_b_v1_5_r1_5 if (treatment==2|treatment==3) & subject==1, by(treatment)

ranksum mean_v1_5_r1_5 if (treatment==1|treatment==2) & subject==1, by(treatment)
ranksum mean_v1_5_r1_5 if (treatment==1|treatment==3) & subject==1, by(treatment)
ranksum mean_v1_5_r1_5 if (treatment==2|treatment==3) & subject==1, by(treatment)


ranksum mean_a_v1_5_r1_5 if (treatment==4|treatment==5) & subject==1, by(treatment)
ranksum mean_a_v1_5_r1_5 if (treatment==4|treatment==6) & subject==1, by(treatment)
ranksum mean_a_v1_5_r1_5 if (treatment==5|treatment==6) & subject==1, by(treatment)

ranksum mean_b_v1_5_r1_5 if (treatment==4|treatment==5) & subject==1, by(treatment)
ranksum mean_b_v1_5_r1_5 if (treatment==4|treatment==6) & subject==1, by(treatment)
ranksum mean_b_v1_5_r1_5 if (treatment==5|treatment==6) & subject==1, by(treatment)

ranksum mean_v1_5_r1_5 if (treatment==4|treatment==5) & subject==1, by(treatment)
ranksum mean_v1_5_r1_5 if (treatment==4|treatment==6) & subject==1, by(treatment)
ranksum mean_v1_5_r1_5 if (treatment==5|treatment==6) & subject==1, by(treatment)


/*** payoffs high treatments ***/

ranksum mean_v1_p1_5 if (treatment==1|treatment==2) & subject==1 & g1==1, by(treatment)
ranksum mean_v1_p1_5 if (treatment==1|treatment==3) & subject==1 & g1==1, by(treatment)
ranksum mean_v1_p1_5 if (treatment==2|treatment==3) & subject==1 & g1==1, by(treatment)

ranksum mean_v2_p1_5 if (treatment==1|treatment==2) & subject==1 & g2==1, by(treatment)
ranksum mean_v2_p1_5 if (treatment==1|treatment==3) & subject==1 & g2==1, by(treatment)
ranksum mean_v2_p1_5 if (treatment==2|treatment==3) & subject==1 & g2==1, by(treatment)

ranksum mean_v2_p1_5 if (treatment==1|treatment==2) & subject==1 & g2==0, by(treatment)
ranksum mean_v2_p1_5 if (treatment==1|treatment==3) & subject==1 & g2==0, by(treatment)
ranksum mean_v2_p1_5 if (treatment==2|treatment==3) & subject==1 & g2==0, by(treatment)

ranksum mean_v2_p1_5 if (treatment==1|treatment==2) & subject==1, by(treatment)
ranksum mean_v2_p1_5 if (treatment==1|treatment==3) & subject==1, by(treatment)
ranksum mean_v2_p1_5 if (treatment==2|treatment==3) & subject==1, by(treatment)

ranksum mean_v3_p1_5 if (treatment==1|treatment==2) & subject==1 & g3==1, by(treatment)
ranksum mean_v3_p1_5 if (treatment==1|treatment==3) & subject==1 & g3==1, by(treatment)
ranksum mean_v3_p1_5 if (treatment==2|treatment==3) & subject==1 & g3==1, by(treatment)

ranksum mean_v3_p1_5 if (treatment==1|treatment==2) & subject==1 & g3==0, by(treatment)
ranksum mean_v3_p1_5 if (treatment==1|treatment==3) & subject==1 & g3==0, by(treatment)
ranksum mean_v3_p1_5 if (treatment==2|treatment==3) & subject==1 & g3==0, by(treatment)

ranksum mean_v3_p1_5 if (treatment==1|treatment==2) & subject==1, by(treatment)
ranksum mean_v3_p1_5 if (treatment==1|treatment==3) & subject==1, by(treatment)
ranksum mean_v3_p1_5 if (treatment==2|treatment==3) & subject==1, by(treatment)

ranksum mean_v4_p1_5 if (treatment==1|treatment==2) & subject==1 & g4==1, by(treatment)
ranksum mean_v4_p1_5 if (treatment==1|treatment==3) & subject==1 & g4==1, by(treatment)
ranksum mean_v4_p1_5 if (treatment==2|treatment==3) & subject==1 & g4==1, by(treatment)

ranksum mean_v4_p1_5 if (treatment==1|treatment==2) & subject==1 & g4==0, by(treatment)
ranksum mean_v4_p1_5 if (treatment==1|treatment==3) & subject==1 & g4==0, by(treatment)
ranksum mean_v4_p1_5 if (treatment==2|treatment==3) & subject==1 & g4==0, by(treatment)

ranksum mean_v4_p1_5 if (treatment==1|treatment==2) & subject==1, by(treatment)
ranksum mean_v4_p1_5 if (treatment==1|treatment==3) & subject==1, by(treatment)
ranksum mean_v4_p1_5 if (treatment==2|treatment==3) & subject==1, by(treatment)

ranksum mean_v5_p1_5 if (treatment==1|treatment==2) & subject==1 & g5==1, by(treatment)
ranksum mean_v5_p1_5 if (treatment==1|treatment==3) & subject==1 & g5==1, by(treatment)
ranksum mean_v5_p1_5 if (treatment==2|treatment==3) & subject==1 & g5==1, by(treatment)

ranksum mean_v5_p1_5 if (treatment==1|treatment==2) & subject==1 & g5==0, by(treatment)
ranksum mean_v5_p1_5 if (treatment==1|treatment==3) & subject==1 & g5==0, by(treatment)
ranksum mean_v5_p1_5 if (treatment==2|treatment==3) & subject==1 & g5==0, by(treatment)

ranksum mean_v5_p1_5 if (treatment==1|treatment==2) & subject==1, by(treatment)
ranksum mean_v5_p1_5 if (treatment==1|treatment==3) & subject==1, by(treatment)
ranksum mean_v5_p1_5 if (treatment==2|treatment==3) & subject==1, by(treatment)

/*** payoffs low treatments ***/

ranksum mean_v1_p1_5 if (treatment==4|treatment==5) & subject==1 & g1==1, by(treatment)
ranksum mean_v1_p1_5 if (treatment==4|treatment==6) & subject==1 & g1==1, by(treatment)
ranksum mean_v1_p1_5 if (treatment==5|treatment==6) & subject==1 & g1==1, by(treatment)

*ranksum mean_v2_p1_5 if (treatment==4|treatment==5) & subject==1 & g2==1, by(treatment)
*ranksum mean_v2_p1_5 if (treatment==4|treatment==6) & subject==1 & g2==1, by(treatment)
ranksum mean_v2_p1_5 if (treatment==5|treatment==6) & subject==1 & g2==1, by(treatment)

ranksum mean_v2_p1_5 if (treatment==4|treatment==5) & subject==1 & g2==0, by(treatment)
ranksum mean_v2_p1_5 if (treatment==4|treatment==6) & subject==1 & g2==0, by(treatment)
ranksum mean_v2_p1_5 if (treatment==5|treatment==6) & subject==1 & g2==0, by(treatment)

ranksum mean_v2_p1_5 if (treatment==4|treatment==5) & subject==1, by(treatment)
ranksum mean_v2_p1_5 if (treatment==4|treatment==6) & subject==1, by(treatment)
ranksum mean_v2_p1_5 if (treatment==5|treatment==6) & subject==1, by(treatment)

ranksum mean_v3_p1_5 if (treatment==4|treatment==5) & subject==1 & g3==1, by(treatment)
ranksum mean_v3_p1_5 if (treatment==4|treatment==6) & subject==1 & g3==1, by(treatment)
ranksum mean_v3_p1_5 if (treatment==5|treatment==6) & subject==1 & g3==1, by(treatment)

ranksum mean_v3_p1_5 if (treatment==4|treatment==5) & subject==1 & g3==0, by(treatment)
ranksum mean_v3_p1_5 if (treatment==4|treatment==6) & subject==1 & g3==0, by(treatment)
ranksum mean_v3_p1_5 if (treatment==5|treatment==6) & subject==1 & g3==0, by(treatment)

ranksum mean_v3_p1_5 if (treatment==4|treatment==5) & subject==1, by(treatment)
ranksum mean_v3_p1_5 if (treatment==4|treatment==6) & subject==1, by(treatment)
ranksum mean_v3_p1_5 if (treatment==5|treatment==6) & subject==1, by(treatment)

ranksum mean_v4_p1_5 if (treatment==4|treatment==5) & subject==1 & g4==1, by(treatment)
ranksum mean_v4_p1_5 if (treatment==4|treatment==6) & subject==1 & g4==1, by(treatment)
ranksum mean_v4_p1_5 if (treatment==5|treatment==6) & subject==1 & g4==1, by(treatment)

ranksum mean_v4_p1_5 if (treatment==4|treatment==5) & subject==1 & g4==0, by(treatment)
ranksum mean_v4_p1_5 if (treatment==4|treatment==6) & subject==1 & g4==0, by(treatment)
ranksum mean_v4_p1_5 if (treatment==5|treatment==6) & subject==1 & g4==0, by(treatment)

ranksum mean_v4_p1_5 if (treatment==4|treatment==5) & subject==1, by(treatment)
ranksum mean_v4_p1_5 if (treatment==4|treatment==6) & subject==1, by(treatment)
ranksum mean_v4_p1_5 if (treatment==5|treatment==6) & subject==1, by(treatment)

ranksum mean_v5_p1_5 if (treatment==4|treatment==5) & subject==1 & g5==1, by(treatment)
ranksum mean_v5_p1_5 if (treatment==4|treatment==6) & subject==1 & g5==1, by(treatment)
ranksum mean_v5_p1_5 if (treatment==5|treatment==6) & subject==1 & g5==1, by(treatment)

ranksum mean_v5_p1_5 if (treatment==4|treatment==5) & subject==1 & g5==0, by(treatment)
ranksum mean_v5_p1_5 if (treatment==4|treatment==6) & subject==1 & g5==0, by(treatment)
ranksum mean_v5_p1_5 if (treatment==5|treatment==6) & subject==1 & g5==0, by(treatment)

ranksum mean_v5_p1_5 if (treatment==4|treatment==5) & subject==1, by(treatment)
ranksum mean_v5_p1_5 if (treatment==4|treatment==6) & subject==1, by(treatment)
ranksum mean_v5_p1_5 if (treatment==5|treatment==6) & subject==1, by(treatment)


*** Comparison of payoffs between A and B over all phases ***/

gen mean_a_v1_p1_5 = mean_v1_p1_5 if g1==1
gen mean_a_v2_p1_5 = mean_v2_p1_5 if g2==1
gen mean_a_v3_p1_5 = mean_v3_p1_5 if g3==1
gen mean_a_v4_p1_5 = mean_v4_p1_5 if g4==1
gen mean_a_v5_p1_5 = mean_v5_p1_5 if g5==1

gen mean_b_v1_p1_5 = mean_v1_p1_5 if g1==0
gen mean_b_v2_p1_5 = mean_v2_p1_5 if g2==0
gen mean_b_v3_p1_5 = mean_v3_p1_5 if g3==0
gen mean_b_v4_p1_5 = mean_v4_p1_5 if g4==0
gen mean_b_v5_p1_5 = mean_v5_p1_5 if g5==0

replace mean_a_v1_p1_5 = 0 if mean_a_v1_p1_5==.
replace mean_a_v2_p1_5 = 0 if mean_a_v2_p1_5==.
replace mean_a_v3_p1_5 = 0 if mean_a_v3_p1_5==.
replace mean_a_v4_p1_5 = 0 if mean_a_v4_p1_5==.
replace mean_a_v5_p1_5 = 0 if mean_a_v5_p1_5==.

replace mean_b_v1_p1_5 = 0 if mean_b_v1_p1_5==.
replace mean_b_v2_p1_5 = 0 if mean_b_v2_p1_5==.
replace mean_b_v3_p1_5 = 0 if mean_b_v3_p1_5==.
replace mean_b_v4_p1_5 = 0 if mean_b_v4_p1_5==.
replace mean_b_v5_p1_5 = 0 if mean_b_v5_p1_5==.

gen mean_a_v1_5_p1_5 = (mean_a_v1_p1_5+mean_a_v2_p1_5+mean_a_v3_p1_5+mean_a_v4_p1_5+mean_a_v5_p1_5)/a_v1_5
gen mean_b_v1_5_p1_5 = (mean_b_v1_p1_5+mean_b_v2_p1_5+mean_b_v3_p1_5+mean_b_v4_p1_5+mean_b_v5_p1_5)/b_v1_5

ranksum mean_a_v1_5_p1_5 if (treatment==1|treatment==2) & subject==1, by(treatment)
ranksum mean_a_v1_5_p1_5 if (treatment==1|treatment==3) & subject==1, by(treatment)
ranksum mean_a_v1_5_p1_5 if (treatment==2|treatment==3) & subject==1, by(treatment)

ranksum mean_b_v1_5_p1_5 if (treatment==1|treatment==2) & subject==1, by(treatment)
ranksum mean_b_v1_5_p1_5 if (treatment==1|treatment==3) & subject==1, by(treatment)
ranksum mean_b_v1_5_p1_5 if (treatment==2|treatment==3) & subject==1, by(treatment)

ranksum mean_v1_5_p1_5 if (treatment==1|treatment==2) & subject==1, by(treatment)
ranksum mean_v1_5_p1_5 if (treatment==1|treatment==3) & subject==1, by(treatment)
ranksum mean_v1_5_p1_5 if (treatment==2|treatment==3) & subject==1, by(treatment)


ranksum mean_a_v1_5_p1_5 if (treatment==4|treatment==5) & subject==1, by(treatment)
ranksum mean_a_v1_5_p1_5 if (treatment==4|treatment==6) & subject==1, by(treatment)
ranksum mean_a_v1_5_p1_5 if (treatment==5|treatment==6) & subject==1, by(treatment)

ranksum mean_b_v1_5_p1_5 if (treatment==4|treatment==5) & subject==1, by(treatment)
ranksum mean_b_v1_5_p1_5 if (treatment==4|treatment==6) & subject==1, by(treatment)
ranksum mean_b_v1_5_p1_5 if (treatment==5|treatment==6) & subject==1, by(treatment)

ranksum mean_v1_5_p1_5 if (treatment==4|treatment==5) & subject==1, by(treatment)
ranksum mean_v1_5_p1_5 if (treatment==4|treatment==6) & subject==1, by(treatment)
ranksum mean_v1_5_p1_5 if (treatment==5|treatment==6) & subject==1, by(treatment)


/*** Comparison of payoffs over A and B for the 25 percent of groups with the lowest payoffs ***/

gen lowpay = 0
replace lowpay = 1 if group==1| group==9| group==12| group==16| group==17| ///
group==25| group==30| group==36| group==39| group==40| ///
group==41| group==44| group==51| group==53| group==58| ///
group==61| group==67| group==77| group==78| group==80| ///
group==81| group==85| group==87| group==88| group==100| ///
group==111| group==112| group==116| group==117| group==118

ranksum mean_v1_5_p1_5 if (treatment==1|treatment==2) & subject==1 & lowpay==1, by(treatment)
ranksum mean_v1_5_p1_5 if (treatment==1|treatment==3) & subject==1 & lowpay==1, by(treatment)
ranksum mean_v1_5_p1_5 if (treatment==2|treatment==3) & subject==1 & lowpay==1, by(treatment)

ranksum mean_v1_5_p1_5 if (treatment==4|treatment==5) & subject==1 & lowpay==1, by(treatment)
ranksum mean_v1_5_p1_5 if (treatment==4|treatment==6) & subject==1 & lowpay==1, by(treatment)
ranksum mean_v1_5_p1_5 if (treatment==5|treatment==6) & subject==1 & lowpay==1, by(treatment)


/***************
Difference in contributions between high and low payoffs
***************/

ranksum mean_v1_r1_5 if (treatment==1|treatment==4) & g1==1 & subject==1, by(treatment)
ranksum mean_v1_r1_5 if (treatment==2|treatment==5) & g1==1 & subject==1, by(treatment)
ranksum mean_v1_r1_5 if (treatment==3|treatment==6) & g1==1 & subject==1, by(treatment)


*ranksum mean_v2_r1_5 if (treatment==1|treatment==4) & g2==1 & subject==1, by(treatment)
ranksum mean_v2_r1_5 if (treatment==2|treatment==5) & g2==1 & subject==1, by(treatment)
ranksum mean_v2_r1_5 if (treatment==3|treatment==6) & g2==1 & subject==1, by(treatment)

ranksum mean_v2_r1_5 if (treatment==1|treatment==4) & g2==0 & subject==1, by(treatment)
ranksum mean_v2_r1_5 if (treatment==2|treatment==5) & g2==0 & subject==1, by(treatment)
ranksum mean_v2_r1_5 if (treatment==3|treatment==6) & g2==0 & subject==1, by(treatment)

ranksum mean_v2_r1_5 if (treatment==1|treatment==4) & subject==1, by(treatment)
ranksum mean_v2_r1_5 if (treatment==2|treatment==5) & subject==1, by(treatment)
ranksum mean_v2_r1_5 if (treatment==3|treatment==6) & subject==1, by(treatment)


ranksum mean_v3_r1_5 if (treatment==1|treatment==4) & g3==1 & subject==1, by(treatment)
ranksum mean_v3_r1_5 if (treatment==2|treatment==5) & g3==1 & subject==1, by(treatment)
ranksum mean_v3_r1_5 if (treatment==3|treatment==6) & g3==1 & subject==1, by(treatment)

ranksum mean_v3_r1_5 if (treatment==1|treatment==4) & g3==0 & subject==1, by(treatment)
ranksum mean_v3_r1_5 if (treatment==2|treatment==5) & g3==0 & subject==1, by(treatment)
ranksum mean_v3_r1_5 if (treatment==3|treatment==6) & g3==0 & subject==1, by(treatment)

ranksum mean_v3_r1_5 if (treatment==1|treatment==4) & subject==1, by(treatment)
ranksum mean_v3_r1_5 if (treatment==2|treatment==5) & subject==1, by(treatment)
ranksum mean_v3_r1_5 if (treatment==3|treatment==6) & subject==1, by(treatment)


ranksum mean_v4_r1_5 if (treatment==1|treatment==4) & g4==1 & subject==1, by(treatment)
ranksum mean_v4_r1_5 if (treatment==2|treatment==5) & g4==1 & subject==1, by(treatment)
ranksum mean_v4_r1_5 if (treatment==3|treatment==6) & g4==1 & subject==1, by(treatment)

ranksum mean_v4_r1_5 if (treatment==1|treatment==4) & g4==0 & subject==1, by(treatment)
ranksum mean_v4_r1_5 if (treatment==2|treatment==5) & g4==0 & subject==1, by(treatment)
ranksum mean_v4_r1_5 if (treatment==3|treatment==6) & g4==0 & subject==1, by(treatment)

ranksum mean_v4_r1_5 if (treatment==1|treatment==4) & subject==1, by(treatment)
ranksum mean_v4_r1_5 if (treatment==2|treatment==5) & subject==1, by(treatment)
ranksum mean_v4_r1_5 if (treatment==3|treatment==6) & subject==1, by(treatment)


ranksum mean_v5_r1_5 if (treatment==1|treatment==4) & g5==1 & subject==1, by(treatment)
ranksum mean_v5_r1_5 if (treatment==2|treatment==5) & g5==1 & subject==1, by(treatment)
ranksum mean_v5_r1_5 if (treatment==3|treatment==6) & g5==1 & subject==1, by(treatment)

ranksum mean_v5_r1_5 if (treatment==1|treatment==4) & g5==0 & subject==1, by(treatment)
ranksum mean_v5_r1_5 if (treatment==2|treatment==5) & g5==0 & subject==1, by(treatment)
ranksum mean_v5_r1_5 if (treatment==3|treatment==6) & g5==0 & subject==1, by(treatment)

ranksum mean_v5_r1_5 if (treatment==1|treatment==4) & subject==1, by(treatment)
ranksum mean_v5_r1_5 if (treatment==2|treatment==5) & subject==1, by(treatment)
ranksum mean_v5_r1_5 if (treatment==3|treatment==6) & subject==1, by(treatment)

ranksum mean_a_v1_5_r1_5 if (treatment==1|treatment==4) & subject==1, by(treatment)
ranksum mean_a_v1_5_r1_5 if (treatment==2|treatment==5) & subject==1, by(treatment)
ranksum mean_a_v1_5_r1_5 if (treatment==3|treatment==6) & subject==1, by(treatment)

ranksum mean_b_v1_5_r1_5 if (treatment==1|treatment==4) & subject==1, by(treatment)
ranksum mean_b_v1_5_r1_5 if (treatment==2|treatment==5) & subject==1, by(treatment)
ranksum mean_b_v1_5_r1_5 if (treatment==3|treatment==6) & subject==1, by(treatment)


/***************
Comparison between cooperative and non-cooperative groups
***************/

by treatment, sort: summarize mean_v1_r1 if subject==1
by treatment, sort: tabulate mean_v1_r1 if subject==1

gen group_coop = 0
replace group_coop = 1 if mean_v1_r1 > 0.5

by group_coop, sort: summarize mean_v1_5_p1_5 if treatment==1 & subject==1
by group_coop, sort: summarize mean_v1_5_p1_5 if treatment==2 & subject==1
by group_coop, sort: summarize mean_v1_5_p1_5 if treatment==3 & subject==1

by group_coop, sort: summarize mean_v1_5_p1_5 if treatment==4 & subject==1
by group_coop, sort: summarize mean_v1_5_p1_5 if treatment==5 & subject==1
by group_coop, sort: summarize mean_v1_5_p1_5 if treatment==6 & subject==1

ranksum mean_v1_5_p1_5 if treatment==1 & subject==1, by(group_coop)
ranksum mean_v1_5_p1_5 if treatment==2 & subject==1, by(group_coop)
ranksum mean_v1_5_p1_5 if treatment==3 & subject==1, by(group_coop)

ranksum mean_v1_5_p1_5 if treatment==4 & subject==1, by(group_coop)
ranksum mean_v1_5_p1_5 if treatment==5 & subject==1, by(group_coop)
ranksum mean_v1_5_p1_5 if treatment==6 & subject==1, by(group_coop)

ranksum mean_v1_5_p1_5 if (treatment==1|treatment==2) & subject==1 & group_coop==1, by(treatment)
ranksum mean_v1_5_p1_5 if (treatment==1|treatment==3) & subject==1 & group_coop==1, by(treatment)
ranksum mean_v1_5_p1_5 if (treatment==2|treatment==3) & subject==1 & group_coop==1, by(treatment)

ranksum mean_v1_5_p1_5 if (treatment==1|treatment==2) & subject==1 & group_coop==0, by(treatment)
ranksum mean_v1_5_p1_5 if (treatment==1|treatment==3) & subject==1 & group_coop==0, by(treatment)
ranksum mean_v1_5_p1_5 if (treatment==2|treatment==3) & subject==1 & group_coop==0, by(treatment)

ranksum mean_v1_5_p1_5 if (treatment==4|treatment==5) & subject==1 & group_coop==1, by(treatment)
ranksum mean_v1_5_p1_5 if (treatment==4|treatment==6) & subject==1 & group_coop==1, by(treatment)
ranksum mean_v1_5_p1_5 if (treatment==5|treatment==6) & subject==1 & group_coop==1, by(treatment)

ranksum mean_v1_5_p1_5 if (treatment==4|treatment==5) & subject==1 & group_coop==0, by(treatment)
ranksum mean_v1_5_p1_5 if (treatment==4|treatment==6) & subject==1 & group_coop==0, by(treatment)
ranksum mean_v1_5_p1_5 if (treatment==5|treatment==6) & subject==1 & group_coop==0, by(treatment)

